package com.pan.controller.spring;


import com.pan.service.BeanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/bean")
public class BeanController {


    @Autowired
    private BeanService beanService;

    /**
     * 打印当前所有的bean
     * @return
     */
    @GetMapping("/printAllBeanName")
    public void printAllBeanName(){

        beanService.printAllBeanName();

    }


    /**
     * 根据名称找到当前bean
     * @return
     */
    @GetMapping("/name")
    public Object getBeanByName(String beanName){

        Object bean = beanService.getBeanByName(beanName);

        return bean;

    }



    /**
     * 根据名称找到当前bean
     * @return
     */
    @GetMapping("/anno")
    public Object getBeansByAnno(String anno){

        Object bean = beanService.getBeanByAnnotation(anno);

        return bean;

    }




}
